package com.itheima.controller.user;

import com.itheima.common.result.Result;
import com.itheima.dto.CommonPageDTO;
import com.itheima.dto.UserDataListVo;
import com.itheima.pojo.YddArticle;
import com.itheima.pojo.YddUser;
import com.itheima.service.YddUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    YddUserService yddUserService;

    @GetMapping("getUserInfo")
    public Result getUserInfo(){
        return yddUserService.getUserInfo();
    }

    @GetMapping("myArticle")
    public Result myArticle(CommonPageDTO dto){
        return yddUserService.myArticle(dto);
    }

    @GetMapping("userDataHandle")
    public Result userDataHandle(@RequestParam Map map){
        return yddUserService.userDataHandle(map);
    }

    @GetMapping("userDataList")
    public Result userDataList(UserDataListVo vo){
        return yddUserService.userDataList(vo);
    }

    @GetMapping("delArticle")
    public Result delArticle(Integer id){
        return yddUserService.delArticle(id);
    }

    @PostMapping("addArticle")
    public Result addArticle(@RequestBody YddArticle article){
        return yddUserService.addArticle(article);
    }


    @PostMapping("editArticle")
    public Result editArticle(@RequestBody YddArticle user){
        return yddUserService.editArticle(user);
    }

    @PostMapping("update")
    public Result updateUser(@RequestBody YddUser user){
        return yddUserService.updateUser(user);
    }

}
